package com.xlro.service;

import com.xlro.dao.BookDao;
import com.xlro.domain.Book;
import org.junit.Test;

import java.util.ArrayList;

import static org.junit.Assert.*;

public class BookServiceTest {

    private BookDao bookDao = new BookDao();

    @Test
    public void getAllBooks() {
        BookService bookService = new BookService();
        ArrayList<Book> books = bookService.getAllBooks();
        for (Book book :
                books) {
            System.out.println(book.getName());
        }
    }

    @Test
    public void getBook() {
        ArrayList<Book> books = bookDao.getAllBook();
        Book book = null;
        for (Book b:books
        ) {
            if("1".equals(b.getId())){
                book = b;
            }
        }
        System.out.println(book.getDesc());
    }
}